#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <grpcpp/grpcpp.h>
#include "../protos/FusionData.grpc.pb.h"
#include "../protos/FusionData.pb.h"
#include "../atomic_include/FusionData.h"

class FusionData_Service_Client {
public:
    FusionData_Service_Client(std::shared_ptr<::grpc::Channel> channel)
        : stub_(::FusionData_Package::FusionData_Service::NewStub(channel)){}
    

    FusionOutput getFusionData(const FusionInput& FusionData_Request_t){
        FusionData_Package::FusionInput request;
        
        
        request.set_camera_id(FusionData_Request_t.camera_id);
        
        
        
        request.set_robot_id(FusionData_Request_t.robot_id);
        
        
        //Received reply data translate to FusionData_Reply_t; 
        FusionOutput FusionData_Reply_t;
        FusionData_Package::FusionOutput reply;
        ::grpc::ClientContext context;
        ::grpc::Status status = stub_->getFusionData(&context, request, &reply);
        
        
        FusionData_Reply_t.number1 = reply.number1();
        
        
        
        FusionData_Reply_t.number2 = reply.number2();
        
        
        
        FusionData_Reply_t.return_type = reply.return_type();
        
        
        if (status.ok()) {
            std::cout << "FusionData--> getFusionData : Received server data success " << std::endl;
        } else {
            std::cout << "FusionData--> getFusionData :" << status.error_code() << ": " << status.error_message() << std::endl;
        }
        return FusionData_Reply_t;
    }

    
private:
    std::unique_ptr<::FusionData_Package::FusionData_Service::Stub> stub_;
};